package com.codejiwei.core.rdd

import org.apache.spark.{SparkConf, SparkContext}

object Spark_Operator_MapPartitions {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[1]").setAppName("MapPartitions")
    val sc = new SparkContext(conf)
    val rdd = sc.makeRDD(List(1, 2, 3, 4, 5), 3)
      .mapPartitions(iter => {
        println("********************************")
        iter.map(_ * 2)
      })

    rdd.collect().foreach(println)

    sc.stop()
  }
}
